package com.zlyx.easy.dev.controller;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.zlyx.easy.core.model.ResultModel;
import com.zlyx.easy.dev.remote.RemoteUtils;

import io.swagger.annotations.Api;

@Api(hidden = true)
@RestController
@RequestMapping("/remote")
public class RemoteController {

	@RequestMapping("/method/call")
	public Object remoteMethod(@RequestBody String body) {
		try {
			JSONObject methodInfo = JSONObject.parseObject(body);
			return ResultModel.success(RemoteUtils.callMethod(methodInfo.getJSONObject("method"), methodInfo.getJSONArray("args").toArray()));
		} catch (Exception e) {
			return ResultModel.err(e);
		}
	}
}    
